# coding: utf-8

from enum import unique

from common.constant import StatusEnum


@unique
class CallState(StatusEnum):
    """
    外呼状态
    """
    BUSY = (-1, '被叫忙')
    INVALID_CALL = (-2, '无拨号音（模拟线）')
    TIMEOUT = (-3, '被叫超时无应答')
    INVALID_NUMBER = (-4, '空号码')
    NO_BACK_TONE = (-5, '无回铃音')
    OTHER_ERROR = (-6, '其它错误')
    CANCLE_CALL = (-88, '取消呼叫')

    WAITING = (0, '待呼叫')
    DIALING = (100, '拨号中')
    ALERTING = (180, '对方振铃')
    CONNECTED = (200, '对方已摘机')
    ONQUEUE = (202, '呼叫进入队列')
    TALKING = (888, '坐席已摘机')
    RECORDFILE = (999, '通话录音文件')
    TALKEND = (1000, '通话结束')
    CALLOVER = (1001, '通话结束')


@unique
class CallReason(StatusEnum):
    """
    外呼原因
    """
    MISS_CALLBACK = (1, '未接电话自动回呼')
    TRY_AGAIN = (2, '呼出未成功，重试呼出')
    INVALID_TALK = (3, '上次呼出未有效沟通')
    LEAVE_CALLBACK = (4, '留电自动回呼')
    XUNKE_CALLBACK = (5, '百度寻客留电自动回呼')
    VISIT_CALLBACK = (6, '回访客户')
    BOOK_CALLBACK = (7, '预约再次回访客户')
    REGULAR_CALLBACK = (8, '定期回访工程商')
    INVITE_NEW_USER = (9, '邀请新工程商')
    BING_WX_CALLBACK = (10, '工程商约定绑定，但未绑定')
    CANCEL_ATTENTION = (11, '工程商取消关注')
    LIVENESS_DROP = (12, '工程商活跃度降低')
    NOT_RENEW = (13, '工程商不续费')
    PAY_FAILED = (14, '工程商尝试付费，但未成功')
    PARTIC_FAILED = (15, '工程商抢单后无余额')
    CUSTOMER_CALL_FAIL = (16, '工程商反馈联系不上客户')
    DELAY_RECALL_CLIENT = (17, '延时处理回呼客户')
    MARKETING_CALLBACK = (18, '金银牌推广- 2次呼叫')


CallReasonWeight = {
    CallReason.MISS_CALLBACK.value: 100,
    CallReason.TRY_AGAIN.value: 1000,
    CallReason.INVALID_TALK.value: 1000,
    CallReason.LEAVE_CALLBACK.value: 100,
    CallReason.XUNKE_CALLBACK.value: 100,
    CallReason.VISIT_CALLBACK.value: 500,
    CallReason.BOOK_CALLBACK.value: 1000,
    CallReason.REGULAR_CALLBACK.value: 1000,
    CallReason.INVITE_NEW_USER.value: 1000,
    CallReason.BING_WX_CALLBACK.value: 1000,
    CallReason.CANCEL_ATTENTION.value: 100,
    CallReason.LIVENESS_DROP.value: 500,
    CallReason.NOT_RENEW.value: 100,
    CallReason.PAY_FAILED.value: 100,
    CallReason.PARTIC_FAILED.value: 1000,
    CallReason.CUSTOMER_CALL_FAIL.value: 500,
}


@unique
class QueueState(StatusEnum):
    """
    外呼记录在队列中的状态
    """
    CANCEL = (0, '已取消')
    WAITING = (1, '待处理')
    HANDLING = (2, '处理中')
    DONE = (3, '已处理')
    CALLING = (4, '通话中')


ALLOW_FILES = ['mp3', 'wav']


